package me.spring.cloud.common.components.rabbitmq.configuration.simple;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;

/**
 * @author luffy
 * @description: 手续实现自定义队列
 * @date 2019-05-24 16:35
 */
public abstract class AbstractSimpleQueueConfiguration implements SimpleQueueConfiguration {

  /**
   * @Return org.springframework.amqp.core.DirectExchange
   * @Author luffy
   * @Description 创建交换机
   * @Date 2019-05-24 16:37
   * @Param []
   **/
  protected DirectExchange creeateExchange() {
    return new DirectExchange(defineExchangeName());
  }

  /**
   * @Return org.springframework.amqp.core.Queue
   * @Author luffy
   * @Description 创建队列
   * @Date 2019-05-24 16:38
   * @Param []
   **/
  protected Queue createQueue() {
    return new Queue(defineQueueName(), true);
  }

  /**
   * @Return org.springframework.amqp.core.Queue
   * @Author luffy
   * @Description 绑定队列和交换机
   * @Date 2019-05-24 16:38
   * @Param []
   **/
  protected Binding createBinding() {
    return BindingBuilder.bind(createQueueBean()).to(creeateExchangeBean()).with(defineQueueName());
  }
}
